import request from '@/utils/request'
import type{ QueryParams, RuleForm } from "@/views/market/management/types";
// 查询所有团购券
export function listAllTicket() {
  return request({
    url: '/ticket/listAll',
    method: 'get'
  })
}

// 查询团购券列表
export function listTicket(query: QueryParams) {
  return request({
    url: '/ticket',
    method: 'get',
    params: query
  })
}

// 分页查询团购券列表
export function listTicketByPage(query: QueryParams) {
  return request({
    url: '/ticket/page',
    method: 'get',
    params: query
  })
}

// 根据id查询团购券
export function getTicketById(ticketId: string) {
  return request({
    url: '/ticket/' + ticketId,
    method: 'get'
  })
}

// 根据名称查询团购券
export function getTicketByName(ticketName: string) {
  return request({
    url: '/ticket/byName/' + ticketName,
    method: 'get'
  })
}

// 新增团购券
export function addTicket(data: RuleForm) {
  return request({
    url: '/ticket/addTicket',
    method: 'post',
    data: data
  })
}

// 修改团购券
export function updateTicket(data: RuleForm) {
  return request({
    url: '/ticket/updateTicket',
    method: 'put',
    data: data
  })
}

// 删除团购券
export function deleteTicket(ticketId: string) {
  return request({
    url: '/ticket/delete/' + ticketId,
    method: 'delete'
  })
}

// 批量删除团购券
export function deleteTicketBatch(ticketIds: string[]) {
  return request({
    url: '/ticket/delBatch/' + ticketIds,
    method: 'delete'
  })
}
